package lagou.FileTest;

import java.io.*;

public class PrintStreamChatTest {
    public static void main(String[] args) {
        BufferedReader b1 = null;
        PrintStream ps = null;
        try {
            b1 = new BufferedReader(new InputStreamReader(System.in));
            ps = new PrintStream(new FileOutputStream("D:/a.txt"));
            while (true) {
                System.out.println("请输入要发送的内容");
                String str = null;
                str = b1.readLine();
                if ("bye".equals(str)) {
                    System.out.println("聊天结束");
                    break;
                } else {
                    ps.println(str);
                }
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            ps.close();
            try {
                b1.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
